import random

print(random.randint(1, 33))

# 随机生成的彩票号码
a = set()

for i in range(8):
    a.add(random.randint(1, 33))

print(a)


# 用户输入的彩票号码
myNub = set()

for i in range(1,9):
    myNub.add(eval(input("请输入{}位数字：".format(i))))


# 中奖号码个数
x = len(myNub & a)

if x == 8:
    print('一等奖')
elif x == 7 :  
    print('二等奖')
elif x == 6 :  
    print('三等奖')
elif x == 5 :  
    print('四等奖')
else :  
    print('没有中奖')


print('================模拟10000次中奖概率==========================')

# 模拟随机购买10000注彩票
count1, count2, count3, count4, count5 = 0, 0, 0, 0, 0
for i in range(10000):
    # 生成一注彩票
    ticket = set()

    for i in range(8):
        ticket.add(random.randint(1, 33))
    # 判断是否中奖
    count = len(ticket & a)

    if count == 8:
        count1 += 1
    elif count == 7:
        count2 += 1
    elif count == 6:
        count3 += 1
    elif count >= 4:
        count4 += 1
    else:
        count5 += 1
# 输出中奖概率
print("一等奖中奖概率为：{:.4f}%".format(count1 / 100))
print("二等奖中奖概率为：{:.4f}%".format(count2 / 100))
print("三等奖中奖概率为：{:.4f}%".format(count3 / 100))
print("四等奖中奖概率为：{:.4f}%".format(count4 / 100))
print("未中奖的概率为：{:.4f}%".format(count5 / 100))
